// location.c

#include "types.h"

static locations_t CurrentLocation;
static int CurrentTime = 0;

locations_t Locations[ MAX_LOCATIONS ] = {
  { "An open field.  You can see in every direction, but you are",
    "open to attack.  A small ditch provides some cover.",
    10, 0, 0, 9 },
  { "A deserted road, with a burned out gas station.  The",
    "building may provide some amount of cover.",
    15, 10, 10, 20 },
  { "A road splitting a forest.  The trees provide some cover,",
    "but also limit visibility.",
    20, 10, 0, 15 },
  { "An isolated neighborhood with a collection of decrepid",
    "houses.  Numerous places to hide.",
    35, 50, 60, 90 },
  { "A road littered with abandoned cars and human remains.",
    "Many places to hide and scavange but still dangerous.",
    20, 30, 20, 50 },
  { "An abandoned schoolhouse surrounded by a chain link fence.",
    "Numerous gaps, but able to be fortified.",
    30, 40, 20, 30 },
  { "A small strip mall containing a mini-mart and gas station.",
    "A horde of zombies gathers at one end.",
    50, 50, 30, 50 },
  { "A shack sitting on the beach of a large lake.  A pile of",
    "burned bodies lies near the location.",
    10, 20, 20, 50 },
  { "A gas station surrounded by a large number of abandoned",
    "vehicles.  Roof access might provide some security.",
    20, 30, 10, 80 },
  { "A small treehouse in a dense wooded area.  While the",
    "treehouse is secure, it has a small footprint.",
    30, 20, 10, 50 },
  { "A abandoned roadside motel with with visibility in all",
    "directions.  Looks like a nice place to hide for a while.",
    30, 50, 30, 75 },
};


int GetZombieDensity( void )
{
   return CurrentLocation.ZombieDensity;
}


int GetFortification( void )
{
   return CurrentLocation.Fortification;
}


int GetTime( void )
{
   return ( CurrentTime % 3 );
}


int GetDay( void )
{
   return ( 1 + ( CurrentTime / 3 ) );
}


char* GetTimeString( void )
{
   char *TimeStrings[3] = { "dawn", "dusk", "nighttime" };

   return ( TimeStrings[ GetTime( ) ] );
}



static void LocationTime( void )
{
   printf( "It is %s, day %d.\n\n", GetTimeString( ), GetDay( ) );
   return;
}


void AdvanceTime( void )
{
   CurrentTime++;
   LocationTime( );
}


void LocationInit( void )
{
   int i;

   CurrentLocation = Locations[ getRand( MAX_LOCATIONS ) ];

   CurrentLocation.ZombieDensity = M_Adjust( CurrentLocation.ZombieDensity );
   CurrentLocation.MaterialDensity = M_Adjust( CurrentLocation.MaterialDensity );
   CurrentLocation.FoodDensity = M_Adjust( CurrentLocation.FoodDensity );
   CurrentLocation.Fortification = M_Adjust( CurrentLocation.Fortification );

   return;
}



void LocationLook( void )
{
   printf( "\n%s\n%s\n", CurrentLocation.description1, CurrentLocation.description2 );
   LocationTime( );
   return;
}



